import 'package:flutter/foundation.dart';

@immutable
class InstallationRecord {
  const InstallationRecord({
    required this.fromVersion,
    required this.toVersion,
  });

  factory InstallationRecord.fromJson(Map<String, dynamic> json) {
    return InstallationRecord(
      fromVersion: json['fromVersion'] as Object,
      toVersion: json['toVersion'] as Object,
    );
  }

  final Object fromVersion;
  final Object toVersion;

  @override
  bool operator ==(Object other) {
    return other.runtimeType == InstallationRecord &&
        other is InstallationRecord &&
        other.fromVersion == fromVersion &&
        other.toVersion == toVersion;
  }

  @override
  int get hashCode {
    return Object.hashAll(<Object?>[
      fromVersion,
      toVersion,
    ]);
  }

  Map<String, dynamic> toJson() {
    return <String, dynamic>{
      'fromVersion': fromVersion,
      'toVersion': toVersion,
    };
  }

  InstallationRecord copyWith({
    Object? fromVersion,
    Object? toVersion,
  }) {
    return InstallationRecord(
      fromVersion: fromVersion ?? this.fromVersion,
      toVersion: toVersion ?? this.toVersion,
    );
  }
}
